<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <button v-on:click="fn">点我啊</button>
        <!-- 如果事件要执行的代码只有一句话，那么可以直接写到行内 -->
        <button v-on:click=" msg = '你好' ">点我啊-写到行内</button>
        <button v-on:mouseenter=" msg = '你好' ">移入我啊-写到行内</button>
        <hr>

        <!-- 简写形式：把v-on:替换成@ -->
        <button @click="fn">点我啊</button>
        <button @click=" msg = '你好' ">点我啊-写到行内</button>
        <button @mouseenter=" msg = '你好' ">移入我啊-写到行内</button>

        <p>{{ msg }}</p>
    </div>
    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    msg: '抠你鸡蛙'
                }
            },
            // methods就是vue里面放方法的地方
            methods: {
                fn () {
                    // console.log('点我干啥？')
                    // 如果在JS部分里要访问vue的数据，前面要加this
                    this.msg = '萨瓦迪卡'
                }
            }
        })
    </script>
</body>
</html>